# 7-1 自除数【函数】
def sDn():
    def selfDivisor(num):
        for digit in str(num):
            if digit == '0' or num % int(digit) != 0:
                return False
        return True

    def find_selfDivisors(N):
        result = []
        for i in range(1, N+1):
            if selfDivisor(i):
                result.append(i)
        return result
    N = int(input())
    selfDivisors = find_selfDivisors(N)
    for num in selfDivisors:
        print(num, end=' ')
# sDn()

# 7-2 反素数【函数】

def RPN():
    def is_prime(num):
        if num < 2:
            return False
        for i in range(2, int(num ** 0.5) + 1):
            if num % i == 0:
                return False
        return True
    def reverse_num(num):
        return int(str(num)[::-1])

    def find_reverse_primes(n):
        def is_reverse_prime(num):
            return is_prime(num) and is_prime(reverse_num(num)) and num != reverse_num(num)

        result = []
        num = 2
        while len(result) < n:
            if is_reverse_prime(num):
                result.append(num)
            num += 1
        return result
    n = int(input())
    reverse_primes = find_reverse_primes(n)
    for num in reverse_primes:
        print(num, end=' ')

# RPN()

# 7-3 贪心的交易【函数】


import random
def max_profit(prices):
    total_profit = 0
    for i in range(1, len(prices)):
        if prices[i] > prices[i-1]:
            total_profit += prices[i] - prices[i-1]
    return total_profit

def main():
    days = int(input())
    random_seed = int(input())
    random.seed(random_seed)
    prices = [random.randint(1, 100) for _ in range(days)]
    print(prices)
    print(max_profit(prices))

# main()

# 7-4 汉诺塔【函数】
def hrt():
    def move(n, a, b, c):
        if n == 1:
            print(a, "-->", c)
        else:
            move(n-1, a, c, b)
            print(a, "-->", c)
            move(n-1, b, a, c)

    n = int(input())
    a, b, c = input().split()
    move(n, a, b, c)
# hrt()

# 7-5 自幂数【函数】

def zimiNum():
    def find_armstrong_numbers(n):
        armstrong_numbers = []
        pow_dict = {str(i): i ** n for i in range(10)}
        for i in range(10 ** (n - 1), 10 ** n):
            num_str = str(i)
            total = sum(pow_dict[digit] for digit in num_str)
            if total == i:
                armstrong_numbers.append(i)
        return armstrong_numbers

    n = int(input())
    armstrong_numbers = find_armstrong_numbers(n)
    for number in armstrong_numbers:
        print(number)
zimiNum()

# 7-6 哥德巴赫猜想【函数】

def caixiang():
    def is_prime(num):
        if num < 2:
            return False
        for i in range(2, int(num ** 0.5) + 1):
            if num % i == 0:
                return False
        return True

    def prime_sum_decomposition(num):
        if num % 2 != 0:
            print("Data error!")
            return

        for i in range(2, num // 2 + 1):
            if is_prime(i) and is_prime(num - i):
                print(f"{num} = {i} + {num - i}")
                break

    n = int(input())
    prime_sum_decomposition(n)
# caixiang()